package logic

import (
	"context"
	"video-system/model/mysql"

	"video-system/userrpc/internal/svc"
	"video-system/userrpc/userrpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type CollectDelLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewCollectDelLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CollectDelLogic {
	return &CollectDelLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 取消收藏
func (l *CollectDelLogic) CollectDel(in *userrpc.CollectDelRequest) (*userrpc.CollectDelResponse, error) {
	// todo: add your logic here and delete this line

	var collect mysql.CollectionInfo

	if err := collect.CollectDel(mysql.DB, in.CollectId); err != nil {
		return nil, err
	}

	return &userrpc.CollectDelResponse{
		CollectId: int64(collect.ID),
	}, nil
}
